<?php
namespace Com\Pay;

class YouyunbaoPay{

    private $config = array();

  
    public function __construct($send_data){
        $this->config = $send_data;
    }


    /*生成支付连接*/
    public function getUrl($order_info,$other = array()){
        $price = $order_info['paymoney'];
        $returnUrl    = $order_info['return_url'];
        $order_sn = $order_info['ordernumber'];
        $post_data = array(
            'pid' => $this->config['mch_id'],
            'money' =>   $price,
            'data'    =>    $order_sn,
            "url"  => $returnUrl,
            "lb"  =>  '3',
            'name' => $order_sn
        );
        $tar_url = "http://pay2.youyunnet.com/pay?" . http_build_query($post_data);
//       $tar_url = 'http://pay1.youyunnet.com/pay?pid=' . $this->config["mch_id"] . '&money=' . $price . '&lb=3&data=' . $order_sn . '&url=' . $returnUrl;
//       $from = "";
//       $from.='<span>订单创建中...</span>';
//       $from.= '<form onload="this.submit()" name="myform" action="'. $tar_url .'" method="post">';
//       $from.='<input type="hidden" name="pid" value="'.$this->config['mch_id'].'"/>';
//       $from.='<input type="hidden" name="money" value="'.$post_data['money'].'"/>';
//       $from.='<input type="hidden" name="data" value="'.$order_sn.'"/>';
//       $from.='<input type="hidden" name="name" value="'.$order_sn.'"/>';
//       $from.='<input type="hidden" name="url" value="'.$returnUrl.'"/>';
//       $from.='<input type="hidden" name="lb" value="3"/>';
//       $from.='<input type="submit" style="display: none" name="Submit" value="确认" />';
//       $from.='<script type="text/javascript">document.myform.submit();</script>';
       return $tar_url;
    }

    //回调方法，把返回数据处理成统一规定返回
    public function response(){
       $data = I("post.");
       if($this->config["mch_key"] === $data['key']) {
           return true;
       }else{
           return false;
       }
    }

}
